package com.zyx.concurrentdemo.mytest.c03;

import lombok.extern.slf4j.Slf4j;

import static com.zyx.concurrentdemo.c02basic.util.Sleeper.sleep;

/**
 * @author Yaxi.Zhang
 * @since 2021/10/12 14:15
 */
@Slf4j(topic = "c.JoinDemo")
public class JoinDemo {
    static int r = 0;

    public static void main(String[] args) {
        test();
    }

    private static void test() {
        log.debug("开始");
        Thread t1 = new Thread(() -> {
            log.debug("开始");
            sleep(1);
            log.debug("结束");
            r = 10;
        });
        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.debug("结果为:{}", r);
        log.debug("结束");
    }


}
